package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.util.List;

@Mapper
public interface UserMapper {



    /**
     * 根据openid 查询用户信息
     * @param openId
     * @return
     */
    @Select("select * from user where openid=#{openId}")
    User selectByOpenId(String openId);

    /**
     *  插入用户信息
     * @param user
     */
    void insert(User user);

    /**
     * 根据id查询用户
     * @param userId
     * @return
     */
    @Select("select * from user where id=#{id}")
    User getById(Long userId);

    /**
     *  根据注册时间 统计每日用户 列表
     * @param time
     * @return
     */
    @Select("select count(id) from user where create_time >= #{time} and create_time < #{nextTime}")
    Integer getNewUserByCreateTime(String time,String nextTime);

    /**
     * 根据注册时间 统计用户总 列表
     * @param time
     * @return
     */
    @Select("select count(id) from user where create_time <= #{time}")
    Integer getTotalUserByCreateTime(String time);
}
